package com.example.rabbitmq.demo01.demo02;

//import com.areio.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String mesg = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,mesg.getBytes());
            System.out.println("发送消息完成："+mesg);
        }
    }
}
